﻿using System;
using System.Windows;
using theeg.GraphWpf.Models;

namespace theeg.GraphWpf.Arrangement
{
    internal class RoutingConfiguration
    {
        internal static RoutingConfiguration Horizontal = new RoutingConfiguration
            {
                GetOffset = x => x.CenterX,
                GetExtent = x => x.Width,
                GetSecondDimensionOffset = x => x.CenterY,
                GetSecondDimensionExtent = x => x.Height,
                ConnectorDefault = ConnectorOrientation.Right,
                ConnectorAlternate = ConnectorOrientation.Left,
                ConnectorSecondDimensionDefault = ConnectorOrientation.Top,
                ConnectorSecondDimensionAlternate = ConnectorOrientation.Bottom,
                CreateIntermediatePoint = (x, y) => new Point(x, y.Y),
                CreateIntermediatePoint2 = (x, y) => new Point(x.X, y),
                CreateIntermediatePoint3 = (x, y) => new Point(x, y)
            };

        internal static RoutingConfiguration Vertical = new RoutingConfiguration
            {
                GetOffset = x => x.CenterY,
                GetExtent = x => x.Height,
                GetSecondDimensionOffset = x => x.CenterX,
                GetSecondDimensionExtent = x => x.Width,
                ConnectorDefault = ConnectorOrientation.Bottom,
                ConnectorAlternate = ConnectorOrientation.Top,
                ConnectorSecondDimensionDefault = ConnectorOrientation.Left,
                ConnectorSecondDimensionAlternate = ConnectorOrientation.Right,
                CreateIntermediatePoint = (y, x) => new Point(x.X, y),
                CreateIntermediatePoint2 = (y, x) => new Point(x, y.Y),
                CreateIntermediatePoint3 = (x, y) => new Point(y, x)
            };

        internal Func<INode, double> GetOffset;
        internal Func<INode, double> GetExtent;
        internal Func<INode, double> GetSecondDimensionOffset;
        internal Func<INode, double> GetSecondDimensionExtent;
        internal Func<double, Point, Point> CreateIntermediatePoint;
        internal Func<Point, double, Point> CreateIntermediatePoint2;
        internal Func<double, double, Point> CreateIntermediatePoint3;

        internal ConnectorOrientation ConnectorDefault;
        internal ConnectorOrientation ConnectorAlternate;
        internal ConnectorOrientation ConnectorSecondDimensionDefault;
        internal ConnectorOrientation ConnectorSecondDimensionAlternate;
    }
}